<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:directive.page import="com.fick.util.General"/>
<jsp:directive.page import="com.fick.hibernate.model.Media"/>
<%@ taglib uri="http://fckeditor.net/tags-fckeditor" prefix="FCK"%>
<%
	String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%
	String title = "添加视频";
	String op = "1"; //当为1表示添加，为2表示编辑
	Media media ;
	if(request.getAttribute("media")!=null){//当为修改操作时
		media =(Media)request.getAttribute("media");
		title = "修改视频";
		op = "2";
	}else{
		media = new Media();
	}
	
	String currPage;
	if(request.getParameter("currPage")!=null){
		currPage = request.getParameter("currPage");
	}else if(request.getAttribute("currPage")!=null){
		currPage = (String)request.getAttribute("currPage");
	}else{
		currPage = "1";
	}
	
	String type="1";
	if(request.getParameter("type")!=null){
		type = request.getParameter("type");
	}else if(request.getAttribute("type")!=null){
		type = (String)request.getAttribute("type");
	}
%>
 
<html>
<head>
<title><%=title %></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="images/jiahao.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="../images/css.css" type="text/css">
<link rel="stylesheet" href="<%=basePath %>/css/style_1.css" type="text/css">
<script type="text/javascript">
var onecount2;
onecount2=0;
subcat2 = new Array();

	function checkForm(){
		if(mediaForm.mediaName.value==""){
			alert("名称不能为空");
			mediaForm.mediaName.focus();
			return false;
		}
		if(mediaForm.mediaUrl.value==""){
			alert("请指定视频路径或链接地址");
			mediaForm.mediaUrl.focus();
			return false;
		}
		return XN_CheckAllCnText();
		
	}
	function XN_CheckAllCnText() 
				{ 
					var str=document.mediaForm.mediaUrl.value;
					var la = str.lastIndexOf('\\')+1;
					str = str.substring(la,str.length);
					var reg=/[\u4E00-\u9FA5]/g 
					if (reg.test(str)){
						alert("视频文件名不能含有汉字");
						return false;
					} 
					str=document.mediaForm.mediaIco.value;
					la = str.lastIndexOf('\\')+1;
					str = str.substring(la,str.length);
					var reg=/[\u4E00-\u9FA5]/g 
					if (reg.test(str)){
						alert("预览图文件名不能含有汉字");
						return false;
					} 
					return true;
				} 
/**
*打开视频选择对话框
*/
function openMediaFileSelect(){
 	var selectImageDialogUrl = "/fckeditor/editor/filemanager/browser/default/browser.html?Type=Media&Connector=/admin/fckeditor/editor/filemanager/browser/default/connectors/jsp/connector";
 	window.open(selectImageDialogUrl,"选择文件",'height=400,width=600,left=200,top=200,status=yes,toolbar=no,menubar=no,location=no');
}	
/**
*打开图片选择对话框
*/
function openImageFileSelect(){
	document.getElementById("nameORico").value="ico";
 	var selectImageDialogUrl = "/fckeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=/admin/fckeditor/editor/filemanager/browser/default/connectors/jsp/connector";
 	window.open(selectImageDialogUrl,"选择文件",'height=400,width=600,left=200,top=200,status=yes,toolbar=no,menubar=no,location=no');
}
/**
*打开文件选择对话框
*/
function openMeidaSelect(){
	document.getElementById("nameORico").value="name";
 	var selectImageDialogUrl = "/fckeditor/editor/filemanager/browser/default/browser.html?Type=Media&Connector=/admin/fckeditor/editor/filemanager/browser/default/connectors/jsp/connector";
 	window.open(selectImageDialogUrl,"选择文件",'height=400,width=600,left=200,top=200,status=yes,toolbar=no,menubar=no,location=no');
}
</script>
</head>


<body bgcolor="#E7F2FE" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td  background="images/main_top.gif" valign="top">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="20" height="23">&nbsp;</td>
            <td class="f14">视频管理</td>
          </tr>
        </table></td>       
      </tr>
    </table>
 <form name="mediaForm" action="/admin/mediaAction.do" method="post" onsubmit="return checkForm();">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">

	<%
		if(op.equals("2")){
			out.println("<input type = 'hidden' name = 'method' value ='update'>");
		}else{
			out.println("<input type = 'hidden' name = 'method' value ='insert'>");
		}
	 %>
  <tr>
    <td height="100%" valign="top"><p>&nbsp;</p>
    <table width="94%" border="0" align="center" cellpadding="0" cellspacing="0">
    	<input type="hidden" name = "id" value = <%=media.getMediaId() %> />
        <tr>
          <td width="72%" align="center" valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="menu_border">
              <tr>
                <td valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="menu">
                    <tr>
                      <td class="menu_ico"></td>
                      <td class="menu_name"><span class="f14"><%=title %></span></td>
                    </tr>
              </table>              </tr>
              <tr>
                <td height="25" bgcolor="#E7F2FE">
                <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#ACCDEC" class="table_margin">
                  <tr>
                    <td height="30" align="right" bgcolor="#E7F2FE" class="css3">视频名称:</td>
                    <td height="30" align="left" bgcolor="#E7F2FE" class="css3">
                    <input name="mediaName"  value="<%=General.convertNullToEmpty(media.getMediaName()) %>"/>
                    </td>
                   <tr>
                    <td height="30" align="right" bgcolor="#E7F2FE" class="css3">视频地址:</td>
                    <td height="30" align="left" bgcolor="#E7F2FE" class="css3">
                    <input name="mediaUrl" id = "filename" value="<%=General.convertNullToEmpty(media.getMediaUrl()) %>"/>
					<input type="button" name="uploadFile" readonly onclick="openMeidaSelect()" value="浏览上传..."/>
                     文件名中不能含有中文
                     <input type="hidden" id="nameORico" value=""/>
                    </td>
                    </tr>
                    <tr>
                    <td height="30" align="right" bgcolor="#E7F2FE" class="css1"><span class="css3">缩略图:</span></td>
                    <td height="30" align="left" bgcolor="#E7F2FE" class="css1">
                    <input type="text" name="mediaIco" id="fileico" value="<%=General.convertNullToEmpty(media.getMediaIco()) %>" readonly/>
                     <input type="button" name="uploadFile" onclick="openImageFileSelect()" value="浏览上传..."/>
                     文件名中不能含有中文
                    <br></td>
                    </tr>
                     
                   <tr>
                    <td height="30" align="right" bgcolor="#E7F2FE" class="css1"><span class="css3">播放时间:</span></td>
                    <td height="30" align="left" bgcolor="#E7F2FE" class="css1">
                    <input type="text" name="mediaPlaytime" value="<%=General.convertNullToEmpty(media.getMediaPlaytime()) %>"><br></td>
                    </tr>
                  
                   <tr>
                    <td height="30" align="right" bgcolor="#E7F2FE" class="css1"><span class="css3">视频介绍:</span></td>
                    <td height="30" align="left" bgcolor="#E7F2FE" class="css1">
                   <FCK:editor id="mediaDescription" basePath="fckeditor/"
						imageBrowserURL="/admin/fckeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector"
						linkBrowserURL="/admin/fckeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector"
						flashBrowserURL="/admin/fckeditor/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector"
						imageUploadURL="/admin/fckeditor/editor/filemanager/upload/simpleuploader?Type=Image"
						linkUploadURL="/admin/fckeditor/editor/filemanager/upload/simpleuploader?Type=File"
						flashUploadURL="/admin/fckeditor/editor/filemanager/upload/simpleuploader?Type=Flash"
						><%=General.convertNullToEmpty(media.getMediaDescription()) %></FCK:editor>
                    </td>
                    </tr>
                    <tr>
                    <td height="30" align="right" bgcolor="#E7F2FE" class="css1"><span class="css3">是否有效:</span></td>
                    <td height="30" bgcolor="#E7F2FE" align="left" class="css1">
                    <input type="radio" name="mediaStatus" value="1" ${media.mediaStatus!="0"?"checked":""}/>有效
                    &nbsp;
                    <input type="radio" name="mediaStatus" value="0" ${media.mediaStatus=="0"?"checked":""}/>无效
                    </td>
                    </tr>
                    <tr>
                    <td height="30" align="right" bgcolor="#E7F2FE" class="css1"><span class="css3">置顶显示:</span></td>
                    <td height="30" bgcolor="#E7F2FE" align="left" class="css1">
                    <input type="radio" name="mediaFirst" value="1" ${media.mediaFirst!="0"?"checked":""}/>不显示
                    &nbsp;
                    <input type="radio" name="mediaFirst" value="0" ${media.mediaFirst=="0"?"checked":""}/>显示
                    </td>
                    </tr>
                    <tr>
                    <td height="30" align="right" bgcolor="#E7F2FE" class="css1"><span class="css3">显示顺序:</span></td>
                    <td height="30" bgcolor="#E7F2FE" align="left" class="css1"><input name="mediaOrder" value="<%=General.convertNullToEmpty(media.getMediaOrder()) %>"></td>
                    </tr>
                    
                  <tr>
                    <td height="40" colspan="2" align="center" valign="middle" bgcolor="#E7F2FE">&nbsp;
                    <input value="提交" type="submit">
                    <input value="返回" type="button" onclick="javascript:history.back(-1);">
                    </td>
                  </tr>
                </table></td>
              </tr>
          </table></td>
        </tr>
      </table></td>
  </tr>
</table>
</form>
</body>
</html>
